package com.nptever.webcamera.impl.request;

import com.nptever.webcamera.utils.PTZCommond;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

/**
 * @author ZhangKai
 * @version 1.0
 * @decription 云台方向控制
 * @date 2018/11/27 16:44
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class PanTilt {

    /**
     * 云台方向控制 x控制横向运动，y控制纵向运动，约定参数如下
     * 上(x:0, y: -1), 下(x:0, y: 1),左(x:1, y: 0),右(x:-1, y: 0)
     */
    @XmlAttribute
    private String x = "1";

    @XmlAttribute
    private String y = "1";

    /**
     * 构造函数
     * @param ptzCommond 构造相应方向参数
     */
    public PanTilt(PTZCommond ptzCommond){

        switch (ptzCommond){
            case MOVE_UP:
                this.setXY("0", "-1");
                break;
            case MOVE_DOWN:
                this.setXY("0", "1");
                break;
            case MOVE_LEFT:
                this.setXY("1", "0");
                break;
            case MOVE_RIGHT:
                this.setXY("-1", "0");
                break;
            default:
                break;
        }
    }

    public void setXY(String x, String y) {
        this.x = x;
        this.y = y;
    }
}
